var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        activity_id: 0,
        hand_goods_obj: {},
        hand_goods_id: 0,
        specsShow: !1,
        goodsPopupShow: !1,
        currentTime: 0,
        timeData: {},
        carList: [],
        language: {},
        networkLoading: !1,
        end_time: "",
        info: {},
        orderParams: {},
        store_id: null
    },
    onChangeTime: function(t) {
        this.setData({
            timeData: t.detail
        });
    },
    close_yz_specs_popup: function(t) {
        if (console.log(t), 1 == t.detail.clicktype) {
            var a = {
                id: t.detail.goodsId,
                total: t.detail.goodsCount,
                optionsId: t.detail.optionsId
            };
            this.data.store_id && (a.store_id = this.data.store_id), this.setData({
                orderParams: a,
                specsShow: !1
            }), this.verifyFrom();
        } else this.setData({
            specsShow: !1
        });
    },
    onLoad: function(t) {
        var e = t.id, o = decodeURIComponent(t.scene);
        if (o) {
            var s = [];
            s = o.split("&"), console.log(s);
            for (var i = 0; i < s.length; i++) {
                var d;
                d = s[i].split("="), console.log(d), "id" == d[0] && (e = d[1]), "mid" == d[0] && a._setMid(d[1]);
            }
            console.log(s);
        }
        t.mid && a._setMid(t.mid), e && 0 != e ? (this.setData({
            activity_id: e,
            info: {},
            timeData: {}
        }), this.getData(e)) : this.tips("参数错误");
    },
    getData: function(t) {
        var e = this, o = a.getNetAddresss("plugin.merchant-meeting.frontend.index.activity");
        a._postNetWork({
            url: o,
            data: {
                activity_id: t
            },
            success: function(t) {
                var a = t.data;
                if (1 !== a.result) return e.tips(a.msg);
                wx.setNavigationBarTitle({
                    title: a.data.plugin_name
                }), e.setData({
                    currentTime: parseInt(new Date().getTime() / 1e3),
                    info: a.data.activity
                });
            }
        });
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    openGoodsDetail: function(t) {
        var a = t.currentTarget.dataset.item;
        a.id == this.data.hand_goods_id ? this.setData({
            goodsPopupShow: !0
        }) : (this.data.hand_goods_id = a.id, this.getGoodsDetails(a.id, "goodsDetails"));
    },
    openSpecs: function(t) {
        var a = t.currentTarget.dataset.item;
        a.id == this.data.hand_goods_id ? this.setData({
            specsShow: !0
        }) : (this.data.hand_goods_id = a.id, this.getGoodsDetails(a.id, "specs"));
    },
    getGoodsDetails: function(e, o) {
        var s = this, i = a.getNetAddresss("goods.goods.get-goods-page");
        a._postNetWork({
            url: i,
            data: {
                id: Number(e)
            },
            success: function(a) {
                var e, i = a.data;
                if (1 !== i.result) return s.tips(i.msg);
                var d = "";
                "goodsDetails" == o ? d = "goodsPopupShow" : "specs" == o && (d = "specsShow"), 
                i.data.get_goods.end_time = 1e3 * (s.data.info.end_time - s.data.currentTime), s.data.store_id = "store_goods" == i.data.goods_type ? i.data.get_store_info.store_id : 0, 
                s.setData((t(e = {}, d, !0), t(e, "hand_goods_obj", i.data.get_goods), e));
            }
        });
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    goodsDetailCartAdd: function(t) {
        this.setData({
            goodsPopupShow: !1,
            specsShow: !0
        });
    },
    verifyFrom: function() {
        var t = this, e = [];
        e.push(t.data.orderParams.id);
        var o = a.getNetAddresss("from.div-from.isDisplay");
        o += "&goods_ids=" + JSON.stringify(e), a._getNetWork({
            showToastIn: !1,
            url: o,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var o = e.data;
                    if (console.log("xxxx", o), e.data.status && !e.data.member_status) wx.showModal({
                        title: "提示",
                        content: "购买此商品,请补充您的个人信息",
                        success: function(t) {
                            t.confirm ? wx.navigateTo({
                                url: "/packageB/member/address/myinfo/myinfo?tag=delta"
                            }) : t.cancel && console.log("用户点击取消");
                        }
                    }); else {
                        var s = "&goodsId=" + t.data.orderParams.id + "&optionsId=" + t.data.orderParams.optionsId + "&total=" + t.data.orderParams.total + "&merchant_meeting=" + t.data.activity_id;
                        t.data.orderParams.store_id && (s = s + "&store_id=" + t.data.orderParams.store_id), 
                        wx.navigateTo({
                            url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2" + s
                        });
                    }
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    onReachBottom: function() {},
    tips: function(t) {
        return wx.showToast({
            title: t,
            icon: "none"
        }), !1;
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            title: this.data.info.title,
            path: "/packageI/offline_investment/offlineInvestmentIndex/offlineInvestmentIndex?id=" + this.data.activity_id + "&mid=" + a
        };
    }
});